package com.distribute.framework.core.web.servlet.upload;

import java.util.Date;

import org.apache.commons.fileupload.ProgressListener;

public class UpLoadProgress implements ProgressListener {
	
	private String task = null;

	private Date start=new Date();

	private String error = null;
	// 文件总长度  
	private long length = 0;  
	// 已上传的文件长度  
	private long currentLength = 0;  
	// 上传是否完成  
	private boolean complete = false;
	//文件保存路径
	private String path=null;
	//文件url
	private String url=null;
	
	private Integer width=0;
	
	private Integer height=0;

	public void update(long bytesRead, long contentLength, int items) {
		this.currentLength = bytesRead; 
		this.length=contentLength;
	}


	public long getLength() {
		return length;
	}


	public void setLength(long length) {
		this.length = length;
	}


	public long getCurrentLength() {
		return currentLength;
	}


	public void setCurrentLength(long currentLength) {
		this.currentLength = currentLength;
	}


	public boolean isComplete() {
		return complete;
	}


	public void setComplete(boolean isComplete) {
		this.complete = isComplete;
	}


	public String getError() {
		return error;
	}


	public void setError(String error) {
		this.error = error;
	}


	public String getPath() {
		return path;
	}


	public void setPath(String path) {
		this.path = path;
	}


	public String getUrl() {
		return url;
	}


	public void setUrl(String url) {
		this.url = url;
	}


	public Date getStart() {
		return start;
	}


	public void setStart(Date start) {
		this.start = start;
	}


	public String getTask() {
		return task;
	}


	public void setTask(String task) {
		this.task = task;
	}


	public Integer getWidth() {
		return width;
	}


	public void setWidth(Integer width) {
		this.width = width;
	}


	public Integer getHeight() {
		return height;
	}


	public void setHeight(Integer height) {
		this.height = height;
	}

	//重新设置文件名
	public void resetNames() {		
		this.url=this.url.substring(0, this.url.lastIndexOf("."))+"0"+this.url.substring(this.url.lastIndexOf("."));
		this.path=this.path.substring(0, this.path.lastIndexOf("."))+"0"+this.path.substring(this.path.lastIndexOf("."));
	}

}